package ntest;

import androidx.appcompat.app.AppCompatActivity;
import androidx.core.widget.TextViewCompat;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.EditText;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.TextView;

import com.example.hello_world.R;

public class bigTask01 extends AppCompatActivity implements View.OnClickListener, RadioGroup.OnCheckedChangeListener, CheckBox.OnCheckedChangeListener {

    private EditText ed;
    private Button button;
    private TextView tx01,tx02,text_RB,text_CB;
    private RadioGroup RG;
    private CheckBox checkBox01,checkBox02,checkBox03;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_big_task01);

        ed=findViewById(R.id.task_edit);
        button=findViewById(R.id.task_button);
        tx01=findViewById(R.id.task_text01);
        tx02=findViewById(R.id.task_text02);
        RG=findViewById(R.id.task_RG);
        checkBox01=findViewById(R.id.task_CB01);
        checkBox02=findViewById(R.id.task_CB02);
        checkBox03=findViewById(R.id.task_CB03);
        text_RB=findViewById(R.id.text_RB);
        text_CB=findViewById(R.id.text_CB);

        button.setOnClickListener(this);
        RG.setOnCheckedChangeListener(this);
        checkBox01.setOnCheckedChangeListener(this);
        checkBox02.setOnCheckedChangeListener(this);
        checkBox03.setOnCheckedChangeListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.task_button:
            String string = ed.getText().toString().trim();
            tx02.setText(string);
            break;
        }
    }

    @Override
    public void onCheckedChanged(RadioGroup group, int checkedId) {
        RadioButton radioButton=findViewById(checkedId);
        String RBstring = radioButton.getText().toString().trim();
        text_RB.setText(RBstring);
    }

    @Override
    public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
        StringBuffer sb=new StringBuffer();


                if (checkBox01.isChecked()){
                    String cb01 = checkBox01.getText().toString();
                    sb.append(cb01+" ");
                }
                if (checkBox02.isChecked()){
                    String cb02 = checkBox02.getText().toString();
                    sb.append(cb02+" ");
                }
               B03:
                if (checkBox03.isChecked()){
                    String cb03 = checkBox03.getText().toString();
                    sb.append(cb03+" ");
                }


        text_CB.setText(sb);
    }
}